﻿<UserControl x:Class="MathematicallySafe.HeadCounter.Views.RaiderGearView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    <UserControl.Resources>
        <DataTemplate x:Key="LootItemTemplate" DataType="LootItem">
            <StackPanel Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center">
                    <Hyperlink TextDecorations="None" NavigateUri="{Binding LootUri}" RequestNavigate="HyperlinkOnRequestNavigate">
                        <TextBlock Style="{StaticResource LootHyperlinkStyle}" Text="{Binding Path=Name}">
                            <TextBlock.ToolTip>
                                <ToolTip Content="{Binding}" Style="{StaticResource ItemTooltipTemplate}" />
                            </TextBlock.ToolTip>
                        </TextBlock>
                    </Hyperlink>
                </TextBlock>
                <TextBlock VerticalAlignment="Center" Text="{Binding iLevel, StringFormat= ({0})}" />
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="ContextMenuItemTemplate">
            <MenuItem Header="{Binding Path=Name}" VerticalContentAlignment="Center"
                      Command="{Binding PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, 
                                Path=DataContext.SelectItemCommand}" 
                      CommandParameter="{Binding}">
                <MenuItem.Icon>
                    <Image Width="24" Height="24" Source="{Binding IconSource}" />
                </MenuItem.Icon>
            </MenuItem>
        </DataTemplate>

        <DataTemplate x:Key="ContextMenuBottomItemTemplate">
            <MenuItem Header="{Binding Path=Name}" VerticalContentAlignment="Center"
                      Command="{Binding PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}, 
                                Path=DataContext.SelectItemBottomSlotCommand}" 
                      CommandParameter="{Binding}">
                <MenuItem.Icon>
                    <Image Width="24" Height="24" Source="{Binding IconSource}" />
                </MenuItem.Icon>
            </MenuItem>
        </DataTemplate>

        <Style x:Key="iLevelTextBlockStyle" TargetType="TextBlock">
            <Setter Property="Margin" Value="0,0,0,2" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="TextAlignment" Value="Center" />
        </Style>

        <Style x:Key="CharSheetIconStyle" TargetType="Image">
            <Setter Property="Height" Value="32" />
            <Setter Property="Width" Value="32" />
        </Style>
        
        <DataTemplate x:Key="IgnoredItemTemplate" DataType="GearViewModel">
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding Offspec}" Content="{Binding Loot.Name}" />
                <TextBlock Margin="4,0" Text="{Binding Loot.Slot, Converter={StaticResource EnumDescriptionConverter}, StringFormat=(\{0\}\, }" />
                <TextBlock Text="{Binding Loot.iLevel, StringFormat=\{0\})}" />
            </StackPanel>
        </DataTemplate>

    </UserControl.Resources>
    
    <DockPanel>
        <DockPanel DockPanel.Dock="Bottom">
            <StackPanel DockPanel.Dock="Left" Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center" >Ignored/Offspec Items: </TextBlock>
                <ComboBox Margin="4,0" VerticalAlignment="Center" ItemsSource="{Binding UnequippedGear}" ItemTemplate="{StaticResource IgnoredItemTemplate}" />
            </StackPanel>
            <Button HorizontalAlignment="Right" Command="{Binding DownloadArmouryDataCommand}">Refresh Gear from Armoury</Button>
        </DockPanel>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
                <RowDefinition Height="50" />
            </Grid.RowDefinitions>

            <DockPanel Grid.Row="0" Grid.Column="0">
                <TextBlock Text="{Binding HeadItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding HeadItem, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding HeadItem.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding HeadItem, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="HeadToolTip" Content="{Binding Path=HeadItem}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedHeadItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <DockPanel Grid.Row="1" Grid.Column="0">
                <TextBlock Text="{Binding NeckItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding NeckItem, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding NeckItem.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding NeckItem, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="NeckToolTip" Content="{Binding Path=NeckItem}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedNeckItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>
            
            <DockPanel Grid.Row="2" Grid.Column="0">
                <TextBlock Text="{Binding ShoulderItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding ShoulderItem, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding ShoulderItem.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding ShoulderItem, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="ShoulderToolTip" Content="{Binding Path=ShoulderItem}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedShoulderItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <DockPanel Grid.Row="3" Grid.Column="0">
                <TextBlock Text="{Binding BackItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding BackItem, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding BackItem.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding BackItem, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="BackToolTip" Content="{Binding Path=BackItem}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedBackItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <DockPanel Grid.Row="4" Grid.Column="0">
                <TextBlock Text="{Binding ChestItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding ChestItem, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding ChestItem.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding ChestItem, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="ChestToolTip" Content="{Binding Path=ChestItem}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedChestItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <DockPanel Grid.Row="5" Grid.Column="0">
                <TextBlock Text="{Binding WristItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding WristItem, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding WristItem.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding WristItem, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="WristToolTip" Content="{Binding Path=WristItem}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedWristItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <DockPanel Grid.Row="0" Grid.Column="2">
                <TextBlock Text="{Binding HandsItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding HandsItem, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding HandsItem.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding HandsItem, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="HandsToolTip" Content="{Binding Path=HandsItem}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedHandsItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <DockPanel Grid.Row="1" Grid.Column="2">
                <TextBlock Text="{Binding WaistItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding WaistItem, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding WaistItem.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding WaistItem, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="WaistToolTip" Content="{Binding Path=WaistItem}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedWaistItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <DockPanel Grid.Row="2" Grid.Column="2">
                <TextBlock Text="{Binding LegsItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding LegsItem, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding LegsItem.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding LegsItem, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="LegsToolTip" Content="{Binding Path=LegsItem}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedLegsItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <DockPanel Grid.Row="3" Grid.Column="2">
                <TextBlock Text="{Binding FeetItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding FeetItem, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding FeetItem.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding FeetItem, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="FeetToolTip" Content="{Binding Path=FeetItem}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedFeetItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <DockPanel Grid.Row="4" Grid.Column="2">
                <TextBlock Text="{Binding Finger1Item.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding Finger1Item, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding Finger1Item.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding Finger1Item, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="Finger1ToolTip" Content="{Binding Path=Finger1Item}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedFingerItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <DockPanel Grid.Row="5" Grid.Column="2">
                <TextBlock Text="{Binding Finger2Item.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding Finger2Item, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding Finger2Item.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding Finger2Item, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="Finger2ToolTip" Content="{Binding Path=Finger2Item}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedFingerItems}" ItemTemplate="{StaticResource ContextMenuBottomItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <DockPanel Grid.Row="6" Grid.Column="2">
                <TextBlock Text="{Binding Trinket1Item.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding Trinket1Item, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding Trinket1Item.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding Trinket1Item, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="Trinket1ToolTip" Content="{Binding Path=Trinket1Item}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedTrinketItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <DockPanel Grid.Row="7" Grid.Column="2">
                <TextBlock Text="{Binding Trinket2Item.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                        Visibility="{Binding Trinket2Item, Converter={StaticResource VisibleIfNull}}" />
                <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding Trinket2Item.IconSource}" MouseEnter="Image_MouseEnter"
                       Visibility="{Binding Trinket2Item, Converter={StaticResource CollapsedIfNull}}">
                    <Image.ToolTip>
                        <ToolTip Name="Trinket2ToolTip" Content="{Binding Path=Trinket2Item}" Style="{StaticResource ItemTooltipTemplate}" />
                    </Image.ToolTip>
                </Image>
                <DockPanel.ContextMenu>
                    <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedTrinketItems}" ItemTemplate="{StaticResource ContextMenuBottomItemTemplate}" />
                </DockPanel.ContextMenu>
            </DockPanel>

            <StackPanel Grid.Column="1" Grid.Row="0" Grid.RowSpan="6" Orientation="Vertical" Margin="16,0">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="0" Grid.IsSharedSizeScope="True" HorizontalAlignment="Stretch" Margin="0,0,8,0">
                        <GroupBox Header="Gear Metrics" Margin="0,0,0,4">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="16" />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>

                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource ControlLabelStyle}" Text="{Binding iLevelBase, StringFormat=Gear Score (Baseline {0}):}" />
                        <TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource NumericDataTextStyle}" Text="{Binding GearScore, StringFormat={}{0:F2}}"/>
                        
                        <TextBlock Grid.Row="0" Grid.Column="3" Style="{StaticResource ControlLabelStyle}">Average iLevel:</TextBlock>
                        <TextBlock Grid.Row="0" Grid.Column="4" Style="{StaticResource NumericDataTextStyle}" Text="{Binding AverageILevel, StringFormat={}{0:F2}}"/>
                        
                        <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource ControlLabelStyle}">Progression Items:</TextBlock>
                        <TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource NumericDataTextStyle}" Text="{Binding ProgressionItemsCount}"/>
                        
                        <TextBlock Grid.Row="2" Grid.Column="3" Style="{StaticResource ControlLabelStyle}">Low Level Items:</TextBlock>
                        <TextBlock Grid.Row="2" Grid.Column="4" Style="{StaticResource NumericDataTextStyle}" Text="{Binding LowLevelItemsCount}"/>
                        
                    </Grid>
                        </GroupBox>

                        <Grid Margin="0,0,0,4">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <GroupBox Grid.Column="0" Header="Best 3 Items" Height="90" >
                                <ItemsControl ItemsSource="{Binding Top3Gear}" ItemTemplate="{StaticResource LootItemTemplate}" />
                            </GroupBox>

                            <GroupBox Grid.Column="1" Header="Worst 3 Items" Height="90">
                                <ItemsControl ItemsSource="{Binding Bottom3Gear}" ItemTemplate="{StaticResource LootItemTemplate}" />
                            </GroupBox>
                        </Grid>
                    </StackPanel>
                </Grid>
            </StackPanel>
            
<!--            WEAPONS-->
            <StackPanel Grid.Column="1" Grid.Row="7"  Orientation="Horizontal" HorizontalAlignment="Center">
                <DockPanel Height="50" Margin="4,0">
                    <TextBlock Text="{Binding MainHandItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                    <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                            Visibility="{Binding MainHandItem, Converter={StaticResource VisibleIfNull}}">
                    </Border>
                    <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding MainHandItem.IconSource}" MouseEnter="Image_MouseEnter"
                           Visibility="{Binding MainHandItem, Converter={StaticResource CollapsedIfNull}}">
                        <Image.ToolTip>
                            <ToolTip Name="MainHandToolTip" Content="{Binding Path=MainHandItem}" Style="{StaticResource ItemTooltipTemplate}" />
                        </Image.ToolTip>
                    </Image>
                    <DockPanel.ContextMenu>
                        <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedMainHandItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                    </DockPanel.ContextMenu>
                </DockPanel>
                <DockPanel Height="50" Margin="4,0">
                    <TextBlock Text="{Binding OffHandItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                    <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                            Visibility="{Binding OffHandItem, Converter={StaticResource VisibleIfNull}}">
                    </Border>
                    <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding OffHandItem.IconSource}" MouseEnter="Image_MouseEnter" 
                           Visibility="{Binding OffHandItem, Converter={StaticResource CollapsedIfNull}}">
                        <Image.ToolTip>
                            <ToolTip Name="OffHandToolTip" Content="{Binding Path=OffHandItem}" Style="{StaticResource ItemTooltipTemplate}" />
                        </Image.ToolTip>
                    </Image>
                    <DockPanel.ContextMenu>
                        <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedOffHandItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                    </DockPanel.ContextMenu>
                </DockPanel>
                <DockPanel Height="50" Margin="4,0">
                    <TextBlock Text="{Binding RangedItem.iLevel}" DockPanel.Dock="Bottom" Style="{StaticResource iLevelTextBlockStyle}" />
                    <Border BorderBrush="DarkGray" BorderThickness="2" CornerRadius="4" Width="32" Background="Transparent"
                            Visibility="{Binding RangedItem, Converter={StaticResource VisibleIfNull}}">
                    </Border>
                    <Image Style="{StaticResource CharSheetIconStyle}" Source="{Binding RangedItem.IconSource}" MouseEnter="Image_MouseEnter"
                           Visibility="{Binding RangedItem, Converter={StaticResource CollapsedIfNull}}">
                        <Image.ToolTip>
                            <ToolTip Name="RangedToolTip" Content="{Binding Path=RangedItem}" Style="{StaticResource ItemTooltipTemplate}" />
                        </Image.ToolTip>
                    </Image>
                    <DockPanel.ContextMenu>
                        <ContextMenu StaysOpen="False" ItemsSource="{Binding UnequippedRangedItems}" ItemTemplate="{StaticResource ContextMenuItemTemplate}" />
                    </DockPanel.ContextMenu>
                </DockPanel>
            </StackPanel>
            
        </Grid>
    </DockPanel>
</UserControl>
